package com.frinder.wx.base.api.tuling.payload;

import lombok.Data;

import java.util.List;

/**
 * @ClassName TuLingResponse
 * @Description //TODO
 * @Author frinder
 * @Date 2018/12/6 15:22
 * @Version 1.0
 */
@Data
public class TuLingResponse {

    public enum ResultType {

        TEXT("text"), URL("url"), IMAGE("image"), VOICE("voice"), VIDEO("video"), NEWS("news");

        String value;

        ResultType(String value) {
            this.value = value;
        }
    }

    /**
     * intent : {"code":10005,"intentName":"","actionName":"","parameters":{"nearby_place":"酒店"}}
     * results : [{"groupType":1,"resultType":"url","values":{"url":"http://m.elong.com/hotel/0101/nlist/#indate=2016-12-10&outdate=2016-12-11&keywords=%E4%BF%A1%E6%81%AF%E8%B7%AF"}},{"groupType":1,"resultType":"text","values":{"text":"亲，已帮你找到相关酒店信息"}}]
     */

    private Intent intent;
    private List<Result> results;


    @Data
    public static class Intent {
        /**
         * code : 10005
         * intentName :
         * actionName :
         * parameters : {"nearby_place":"酒店"}
         */

        private int code;
        private String intentName;
        private String actionName;
        private Parameters parameters;


        @Data
        public static class Parameters {
            /**
             * nearby_place : 酒店
             */

            private String nearby_place;
        }
    }


    @Data
    public static class Result {
        /**
         * groupType : 1
         * resultType : url
         * values : {"url":"http://m.elong.com/hotel/0101/nlist/#indate=2016-12-10&outdate=2016-12-11&keywords=%E4%BF%A1%E6%81%AF%E8%B7%AF"}
         */

        private int groupType;
        private String resultType;
        private Values values;


        @Data
        public static class Values {
            /**
             * url : http://m.elong.com/hotel/0101/nlist/#indate=2016-12-10&outdate=2016-12-11&keywords=%E4%BF%A1%E6%81%AF%E8%B7%AF
             */

            private String url;

            private String text;
        }
    }

    public TuLingResponse error() {
        intent = new Intent();
        intent.code = 8008;
        return this;
    }
}
